#ifndef CURRENTOBSERVERSTRATEGY_H
#define CURRENTOBSERVERSTRATEGY_H

#pragma once

#include <LDFToolkit/ToolkitLayer.h>
#include <LDF/VisComponentStrategy.h>


/**
 * This strategy provides the behavior that responds to a container with a
 * CurrentBeltContainerStrategy. It implements the passive buffer
 * initialization and reading routines so that a component that has this
 * strategy among the ones associated with it will be able to respond to
 * scaling, orientation, and directed movement as given by a current belt
 * container.
 *
 * @author Fabricio Anastacio - fabriciocfa@yahoo.com
 * @since August 27, 2007
 */
class TOOLKITLAYER_API CurrentObserverStrategy : public VisComponentStrategy
{
	// Attributes
protected:
	/** Absolute size buffer type identifier. */
	unsigned int sizeBufferType;
	/** Orientation buffer type identifier. */
	unsigned int orientationBufferType;
	/** Direction buffer type identifier. */
	unsigned int directionBufferType;

	// Methods
public:
	/**
	 * Constructs a current aware strategy.
	 */
	CurrentObserverStrategy(void);
	/**
	 * Destroys this strategy.
	 */
	~CurrentObserverStrategy(void);

	
protected:
	/**
	 * Initializes the properties (i. e., i-buffers) of the associated
	 * component.
	 */
	void initProperties();
	/**
	 * Defines the strategy to be used when the associated component is
	 * "dropped" inside another component (likely, a container). It is called
	 * when the component is processed from the manager's update list. It
	 * usually defines some "decorative" behavior such as triggering
	 * animations, since the composition structure is already managed by the
	 * LargeDisplayManager class. Returns true if this call resulted in
	 * adding the component to a container with animation.
	 *
	 * @param parentChanged true if the component's parent changed with the
	 * dropping.
	 * @return true if this call resulted in adding or keeping the component to
	 * a container with animation, false otherwise.
	 */
	bool drop(bool parentChanged);
	/**
	 * Reads the passive buffer(s) specified by the parameter 'type' and makes
	 * the proper updates in the state of the associated component.
	 *
	 * @param type the type of buffer that should be read from the container.
	 */
	void readPassiveBuffers(const std::vector<unsigned int>& types);
	/**
	 * Reads all the passive buffers for a component strategy. This method is
	 * called before drawing the component in order to update its
	 * state/properties.
	 */
	void readAllPassiveBuffers();
	/**
	 * Reads only the passive buffers for a component strategy that are
	 * necessary for picking processing. This method is called before drawing
	 * the component for picking in order to update its state/properties.
	 */
	void readAllPickingPassiveBuffers();

protected:
	// PASSIVE BUFFER READING
	/**
	 * Updates the scale of the associated component based on a size buffer.
	 */
	void readSize();
	/**
	 * Updates the rotation angle of the associated component based on an
	 * orientation buffer.
	 */
	void readOrientation();
	/**
	 * Updates the position of the associated component based on a direction
	 * buffer.
	 */
	virtual void readDirection();

};

#endif // CURRENTOBSERVERSTRATEGY_H
